package com.im.config;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.im.base.common.box.ConfigBox;
import com.im.server.enterprise.cover.action.DepartmentUserAction;
import com.im.server.general.business.thread.SocketThread;
import com.im.server.handler.ServerHandler;
import com.im.server.special.business.action.SpecialPersonalAction;
import com.im.server.special.business.action.SpecialSettingAction;
import com.only.common.util.OnlyPropertiesUtil;

/**
 * @author XiaHui
 * @date 2017年8月13日 下午7:46:12
 */
@Component
public class ConfigInitialize {

	@Resource
    private SocketThread socketThread;
    @Resource
    ServerHandler serverHandler;
    
    public void initialize() {
    	serverHandler.scan("com.im.server.enterprise.business.action");
    	serverHandler.coverAction(SpecialPersonalAction.class);
    	serverHandler.coverAction(SpecialSettingAction.class);
    	serverHandler.coverAction(DepartmentUserAction.class);
        
		String address = OnlyPropertiesUtil.getProperty("config/setting/config.properties", "remote.server.address");
		ConfigBox.put("remote.server.address", address);
		String port = OnlyPropertiesUtil.getProperty("config/setting/config.properties", "remote.server.port");
		ConfigBox.put("remote.server.port", port);
		address = OnlyPropertiesUtil.getProperty("config/setting/config.properties", "file.server.url");
		ConfigBox.put("file.server.url", address);

        //socketThread.setPort(0);
        socketThread.start();
    }
}
